package com.chapter.sample;

import com.chapter.sample.beans.OtherBean;
import com.chapter.sample.config.SpringConfig;
import com.chapter.sample.dao.UserDao;
import com.chapter.sample.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;
import java.sql.SQLException;

public class ApplicationContextTest {
    public static void main(String[] args) throws SQLException, ClassNotFoundException, IOException {
        //ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml");


        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);
        UserService bean = applicationContext.getBean(UserService.class);
        System.out.println(bean);
        bean.show();

        OtherBean otherBean = applicationContext.getBean(OtherBean.class);
        System.out.println(otherBean);


    }
}
